package com.park.controller;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.park.model.EquipmentStatusMonitoring;
import com.park.model.Paging;
import com.park.service.EquipmentStatusMonitoringService;
import com.park.service.Utility;

@Controller
@RequestMapping("/equipmentStatusMonitoring")
public class EquipmentStatusMonitoringController {
	@Autowired
	private EquipmentStatusMonitoringService equipmentStatusMonitoringService;
	private static Log logger = LogFactory.getLog(EquipmentStatusMonitoringController.class);
	
	@RequestMapping(value = "selectByType", method = RequestMethod.POST, produces = { "application/json;charset=UTF-8" })
	@ResponseBody
	public String selectByType(@RequestBody Map<String, Object> args) {
		logger.info("selectByType参数:"+args);
		int type = (int)args.get("type");
		String value = (String)args.get("value");
		int startPage = (int)args.get("startPage");
		int pageSize = (int)args.get("pageSize");
		List<EquipmentStatusMonitoring> equipmentStatusMonitorings = equipmentStatusMonitoringService.selectByType(type,value,(startPage-1)*pageSize,pageSize);
		int returnCount = equipmentStatusMonitoringService.getCount(type,value);
		Paging page = new Paging(startPage,pageSize,returnCount,equipmentStatusMonitorings);
		Map<String,Object> resultMap = new HashMap<>();
		resultMap.put("status",1001);
		resultMap.put("message","查询成功");
		resultMap.put("data", page);
		logger.info("selectByType返回值ֵ:"+resultMap);
		return Utility.gson.toJson(resultMap);
	}

}
